<?php
include_once "connessione.php";
$id_categoria = $_GET['cat_id'];
$nome_categoria = $_GET['cat_nome'];
$percorso_img = "/admin/plugins/images/eventi";
$percorso_documenti = "/admin/plugins/documents/eventi";
?>
<?php include_once "include/session.php"; ?>
<!DOCTYPE html>
<html class="no-js" lang="en">
<?php include_once "include/head.php"; ?>
<body>
    <!--[if lt IE 8]>
        <p class="browserupgrade">You are using an <strong>outdated</strong> browser. Please <a href="http://browsehappy.com/">upgrade your browser</a> to improve your experience.</p>
    <![endif]-->
    
    <!--  THEME PRELOADER AREA -->
    <div id="preloader-wrapper">
        <div class="preloader-wave-effect"></div>
    </div>
    <!-- THEME PRELOADER AREA END -->     

    <!-- Body main wrapper start -->
    <div class="wrapper">
        <!-- Start of header area -->
        <?php include_once "include/header.php"; ?>
        <!-- End of header area -->
        <!-- Start page content -->
        <div id="page-content" class="page-wrapper">
            <div class="zm-section single-post-wrap bg-white ptb-70 xs-pt-30">
                <div class="container">
                    <div class="row">
                        <!-- Start left side -->
                        <div class="col-xs-12 col-sm-12 col-md-9 col-lg-9 columns">
                            <div class="row">
                                <?php
                                $id_evento = $_GET['id_evento'];
                                if(!preg_match("#^[0-9]+$#", $_GET['id_evento']))
                                    die('Errore parametro');
                                $query_articolo_evento = mysqli_query
                                ($conn, "SELECT * FROM `magazine__eventi`".
                                    " left join magazine__eventi_visibilita on `magazine__eventi`.id = magazine__eventi_visibilita.id_evento WHERE id = $id_evento");
                                $row_articolo_evento = mysqli_fetch_array($query_articolo_evento);
                                // campi json evento
                                $place = json_decode($row_articolo_evento['place']);
                                $referenze = json_decode($row_articolo_evento['referenze']);
                                $contatti = json_decode($row_articolo_evento['contatti']);
                                $day = date("d", strtotime($row_articolo_evento['data_pubblicazione']));
                                $month = date("M", strtotime($row_articolo_evento['data_pubblicazione']));
                                $year = date("Y", strtotime($row_articolo_evento['data_pubblicazione']));

                                $allegati_evento = array();
                                $gallery_evento = array();
                                $query_gallery_evento = mysqli_query($conn, "select * from magazine__eventi_contenuti where contenuto_id = ".$id_evento." and contenuto_tipo like 'gallery'");
                                $query_allegati_evento = mysqli_query($conn, "SELECT contenuto_path, contenuto_titolo FROM magazine__eventi_contenuti WHERE contenuto_tipo = 'allegato' AND contenuto_id = $id_evento");
                                while($row_allegati_evento = mysqli_fetch_array($query_allegati_evento))
                                    $allegati_evento[] = $row_allegati_evento;
                                while($row_gallery_evento = mysqli_fetch_array($query_gallery_evento))
                                    $gallery_evento[] = $row_gallery_evento;

                                $elenco_video_eventi = array();
                                $elenco_video = mysqli_query($conn, "select * from magazine__eventi_video_correlati where id_evento = $id_evento");
                                while($row_elenco_video = mysqli_fetch_array($elenco_video))
                                    $elenco_video_eventi[] = $row_elenco_video;


                                ?>
                                <!-- Start single post image formate-->

                                <?php

                                if(!$row_articolo_evento['pubblico'] && (!isset($utente_session))){

                                }

                                else{
                                    ?>

                                    <div class="col-md-12">
                                        <article class="zm-post-lay-single">
                                            <div class="zm-post-thumb">
                                                <img title="<?php echo $row_articolo_news['titolo']; ?>" src="<?php echo $percorso_img."/".$row_articolo_evento['id']."/".$row_articolo_evento['img_path']; ?>" alt="img">
                                            </div>
                                            <div class="zm-post-dis">
                                                <div class="zm-post-header">
                                                    <h2 class="zm-post-title h2"><a href="#"><?php echo $row_articolo_evento['titolo']; ?></a></h2>
                                                    <div class="zm-post-meta">
                                                        <ul>
                                                            <li class="s-meta"><a href="#" class="zm-author">Redazione OMCeO</a></li>
                                                            <li class="s-meta"><a href="#" class="zm-date"><?php echo $day." ".strtoupper($month)." ".$year; ?></a></li>
                                                        </ul>
                                                    </div>

                                                    <!--
                                                    <div class="fb-share-button" data-href="<?php echo $link_articolo; ?>" data-layout="button_count" data-size="large" data-mobile-iframe="true">
                                                        <a target="_blank" href="https://www.facebook.com/sharer/sharer.php?u=http%3A%2F%2F<?php echo $link_articolo; ?>&amp;src=sdkpreparse" class="fb-xfbml-parse-ignore">Condividi</a>
                                                    </div>
                                                    <style>
                                                        .twitter-share-button {
                                                            vertical-align:bottom !important}
                                                        #li_ui_li_gen_1524137912951_0-title{
                                                            height:28px !important}</style>

                                                    <a  data-size="large" href="https://twitter.com/intent/tweet?text="'.<?php echo $FBtitolo; ?>.'" class="twitter-share-button" data-show-count="true">Tweet to @SCCL12</a>
                                                    <script async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script>

                                                    <script src="//platform.linkedin.com/in.js" type="text/javascript"> lang: it_IT</script>
                                                    <script type="IN/Share" data-format="inline" height="100" data-url="<?php echo $link_articolo; ?>"></script>

                                                    -->

                                                    <div class="sharethis-inline-share-buttons"></div>
                                                </div>
                                                <div class="zm-post-content">
                                                    <p>
                                                        <?php echo $row_articolo_evento['testo_html']; ?>
                                                    </p>
                                                </div>

                                                <div class="zm-post-content ptb-70">
                                                    <div class="section-title">
                                                        <h2 class="h6 fix-padding header-color inline-block uppercase ">DETTAGLI EVENTO</h2>
                                                    </div>
                                                    <style>
                                                        .dett_evento th{
                                                            padding: 15px !important;
                                                        }
                                                        .dett_evento .info_eve{
                                                            font-weight: 300;
                                                            padding: 15px;
                                                        }
                                                    </style>
                                                    <div class="table-content table-responsive zm-table">
                                                        <table class="table dett_evento" style="background: #fafafa; padding: 40px">
                                                            <thead>
                                                            <tr>
                                                                <th class="info_eve">Regione</th>
                                                                <th><?php echo $place->regione; ?></th>
                                                            </tr>
                                                            <tr>
                                                                <th class="info_eve" width="50%">Provincia</th>
                                                                <th width="50%"><?php echo $place->citta; ?></th>
                                                            </tr>
                                                            <tr>
                                                                <th class="info_eve">Città / Comune</th>
                                                                <th><?php echo $place->comune; ?></th>
                                                            </tr>
                                                            <tr>
                                                                <th class="info_eve">Location</th>
                                                                <th><?php echo $place->location; ?></th>
                                                            </tr>
                                                            <tr>
                                                                <th class="info_eve">Indirizzo</th>
                                                                <th><?php echo $place->indirizzo; ?></th>
                                                            </tr>
                                                            <tr>
                                                                <th class="info_eve">Durata Corso</th>
                                                                <th><?php echo $row_articolo_evento['durata_giorni']; ?></th>
                                                            </tr>
                                                            <tr>
                                                                <th class="info_eve">Referenze</th>
                                                                <th><?php echo $referenze->main; ?></th>
                                                            </tr>
                                                            <tr>
                                                                <th class="info_eve">Contatti</th>
                                                                <th><?php echo $contatti->main; ?></th>
                                                            </tr>
                                                            </thead>
                                                            <tbody>
                                                            </tfoot>
                                                        </table>
                                                    </div>
                                                </div>

                                                <?php if(count($elenco_video_eventi)){ ?>
                                                    <div class="col-md-12 zm-post-content ptb-20 mtb-20">
                                                        <div class="section-title">
                                                            <h2 class="h6 header-color inline-block uppercase">Video Correlati</h2>
                                                        </div>
                                                        <?php
                                                        foreach ($elenco_video_eventi as $allegato_video){ ?>

                                                            <div class="col-md-3" style="padding: 5px;">
                                                                <div class="zm-video-post zm-video-lay-c">

                                                                    <div class="zm-video-thumb"  data-dark-overlay="2.5" style="width: 100%" >
                                                                        <img src="<?php echo $allegato_video['anteprima'];?>" alt="video">
                                                                        <a class="fancybox" href="<?php echo $allegato_video['link']; ?>">
                                                                            <i class="fa fa-play-circle-o"></i>
                                                                        </a>
                                                                    </div>

                                                                </div>



                                                            </div>
                                                        <?php } ?>
                                                    </div>
                                                <?php } ?>

                                                <?php if(count($gallery_evento)){ ?>

                                                    <div class="col-md-12 zm-post-content ptb-20 mtb-20">
                                                        <div class="section-title">
                                                            <h2 class="h6 header-color inline-block uppercase">Galleria Foto</h2>
                                                        </div>

                                                        <?php
                                                        foreach ($gallery_evento as $allegato){ ?>
                                                            <div class="col-md-3 mb-5" style="overflow:hidden; height:130px; padding:5px">
                                                                <a data-fancybox="group_gallery" rel="group_gallery" title="<?php echo $allegato['contenuto_titolo'];?>" href="<?php echo $percorso_img."/".$id_evento."/".$allegato['contenuto_path'];?>">
                                                                    <img title="<?php echo $allegato['contenuto_titolo'];?>" src="<?php echo $percorso_img."/".$id_evento."/".$allegato['contenuto_path'];?>">

                                                                </a>
                                                            </div>

                                                        <?php } ?>



                                                    </div>
                                                <?php } ?>

                                                <?php if(count($allegati_evento)){ ?>
                                                    <div class="col-md-12 zm-post-content ptb-70">
                                                        <div class="section-title">
                                                            <h2 class="h6 fix-padding header-color inline-block uppercase ">ALLEGATI EVENTO</h2>
                                                        </div>
                                                        <?php foreach ($allegati_evento as $allegato){ ?>
                                                            <h2 class="zm-post-title h2 ptb-50">
                                                                <img src="/images/pdf.png" />
                                                                <a target="_blank" title="<?php echo $allegato['contenuto_titolo'];?>" href="<?php echo $percorso_documenti."/".$id_evento."/".$allegato['contenuto_path'];?>">
                                                                    <?php echo $allegato['contenuto_titolo'];?>
                                                                </a>
                                                            </h2>
                                                        <?php } ?>
                                                    </div>
                                                <?php } ?>


                                            </div>
                                        </article>
                                    </div>

                                    <?php
                                }

                                ?>


                                <!-- End single post image formate -->
                                <div style="display: none" class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
                                    <nav class="zm-pagination ptb-40 mtb-40 text-center border-bottom border-top">
                                        <ul class="page-numbers clearfix">
                                            <li class=" pull-left"><a class="prev page-numbers" href="#">Previous</a></li>
                                            <li class="pull-right"><a class="next page-numbers" href="#">Next</a></li>
                                        </ul>
                                    </nav>
                                </div>
                                <!--Start Similar post -->
                                <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
                                    <aside class="zm-post-lay-a2-area">
                                        <div class="row mb-40">
                                            <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
                                                <div class="section-title">
                                                    <h2 class="h6 header-color inline-block uppercase">POTREBBE INTERESSARTI</h2>
                                                </div>
                                            </div>
                                        </div>
                                        <div class="row">
                                            <div class="zm-posts clearfix">
                                                <?php
                                                $query_related = mysqli_query($conn, "SELECT * FROM `magazine__eventi` WHERE id != $id_evento AND categoria_id = ".$row_articolo_evento['categoria_id']." LIMIT 3");
                                                while($row_evento_releated = mysqli_fetch_array($query_related)){
                                                    $day = date("d", strtotime($row_evento_releated['data_pubblicazione']));
                                                    $month = date("M", strtotime($row_evento_releated['data_pubblicazione']));
                                                    $year = date("Y", strtotime($row_evento_releated['data_pubblicazione']));
                                                    ?>
                                                    <div class="col-xs-12 col-sm-6 col-md-6 col-lg-4">
                                                        <article class="zm-post-lay-a2">
                                                            <div class="zm-post-thumb">
                                                                <a title="<?php echo $row_evento_releated['titolo']; ?>" href="/evento/<?php echo $row_evento_releated['id']; ?>/<?php echo seoUrl($row_evento_releated['titolo']); ?>">
                                                                    <img title="<?php echo $row_evento_releated['titolo']; ?>" src="<?php echo $percorso_img."/".$row_evento_releated['id']."/".$row_evento_releated['img_path']; ?>" alt="img">
                                                                </a>
                                                            </div>
                                                            <div class="zm-post-dis">
                                                                <div class="zm-post-header">
                                                                    <h2 class="zm-post-title h2"><a title="<?php echo $row_evento_releated['titolo']; ?>" href="/evento/<?php echo $row_evento_releated['id']; ?>/<?php echo seoUrl($row_evento_releated['titolo']); ?>"><?php echo $row_evento_releated['titolo']; ?></a></h2>
                                                                    <div class="zm-post-meta">
                                                                        <ul>
                                                                            <li class="s-meta"><a href="#" class="zm-author">REDAZIONE OMCeO</a></li>
                                                                            <li class="s-meta"><a href="#" class="zm-date"><?php echo $day." ".strtoupper($month)." ".$year; ?></a></li>
                                                                        </ul>
                                                                    </div>
                                                                </div>
                                                            </div>
                                                        </article>
                                                    </div>
                                                <?php } ?>
                                                <!--<div class="col-xs-12 col-sm-6 col-md-4 hidden-md col-lg-4 hidden-sm">
                                                    <article class="zm-post-lay-a2">
                                                        <div class="zm-post-thumb">
                                                            <a href="#"><img src="images/post/a/a2/13.jpg" alt="img"></a>
                                                        </div>
                                                        <div class="zm-post-dis">
                                                            <div class="zm-post-header">
                                                                <h2 class="zm-post-title h2"><a href="#">Lorem ipsum dolor sit amet consectetur.</a></h2>
                                                                <div class="zm-post-meta">
                                                                    <ul>
                                                                        <li class="s-meta"><a href="#" class="zm-author">Thomson Smith</a></li>
                                                                        <li class="s-meta"><a href="#" class="zm-date">April 18, 2016</a></li>
                                                                    </ul>
                                                                </div>
                                                            </div>
                                                        </div>
                                                    </article>
                                                </div>-->
                                            </div>
                                        </div>
                                    </aside>
                                </div>
                            </div>
                        </div>
                        <!-- End left side -->
                        <!-- Start Right sidebar -->
                        <div class="col-xs-12 col-sm-12 col-md-12 col-lg-3 sidebar-warp columns">

                            <div class="row">
                            
                            	<div class="row mb-40">
                                    <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
                                        <div class="section-title">
                                            <h2 class="h6 header-color inline-block uppercase">SEGUICI</h2>
                                        </div>
                                    </div>
                                </div>
                            
                            	<?php include_once "include/likebox-facebook.php"; ?>
                                
                                <div class="row">
                                    <div class="col-xs-12 mb-40">
                                        <div class="advertisement">
                                            <a href="#"><img src="/images/Banner-Card-omceo.png" alt=""></a>
                                        </div>
                                    </div>
                                </div>
                                <div class="row mb-40" style="display:none">
                                    <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
                                        <div class="section-title">
                                            <h2 class="h6 header-color inline-block uppercase">Follow Us</h2>
                                        </div>
                                    </div>
                                </div>
                                <div class="row mb-40" style="display:none">
                                    <div class="col-xs-12">
                                        <div class="followus-area">
                                            <a href="#" class="social-btn large bg-facebook block"><span class="btn_text"><i class="fa fa-facebook"></i>336,784 Likes</span></a>
                                            <a href="#" class="social-btn large bg-twitter block"><span class="btn_text"><i class="fa fa-twitter"></i>548,266 Followers</span></a>
                                            <a href="#" class="social-btn large bg-youtube block"><span class="btn_text"><i class="fa fa-youtube-play"></i>806,457 Subscribers</span></a>
                                            <a href="#" class="social-btn large bg-rss block"><span class="btn_text"><i class="fa fa-rss"></i>755,629 Followers</span></a>
                                            <a href="#" class="social-btn large bg-behance block"><span class="btn_text"><i class="fa fa-behance"></i>755,629 Followers</span></a>
                                        </div>
                                    </div>
                                    <div class="col-xs-12 mt-70">
                                        <div class="advertisement">
                                            <a href="#"><img src="/images/ad/ad_sidebar.png" alt=""></a>
                                        </div>
                                    </div>
                                </div>
                                <?php include_once "eventi_sidebar.php"; ?>
                            </div>
                        </div>
                        <!-- End Right sidebar -->
                    </div>
                </div>
            </div>
        </div>
        <!-- End page content -->
        <!-- Start footer area -->
        <?php include_once "include/footer.php"; ?>
        <!-- End footer area -->
    </div>
    <!-- Body main wrapper end -->

    <?php include_once "include/scripts.php"; ?>

</body>
</html>